﻿using AutoStar.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AutoStar.Views.Pages
{
    /// <summary>
    /// PrintParaView.xaml 的交互逻辑
    /// </summary>
    public partial class PrintParaView : Window
    {
        public PrintParaView()
        {
            InitializeComponent();
            DataContext = Global.printParaVM;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int i = Global.printParaVM.LayerSelected;
            Global.printParaVM.PrintParaLayers = new List<PrintLayer>(Global.printProject.printLayers);
            float height = float.Parse(Global.SliceParaVM.MaxHeight);
            if (i > 0)
            {
                Global.printProject.printLayers.RemoveRange(0, i);
                for (int j = 0; j < Global.printProject.printLayers.Count(); j++)
                {
                    for (int k = 0; k < Global.printProject.printLayers[j].points.Count(); k++)
                    {
                        Global.printProject.printLayers[j].points[k].Z = (height * j) + 0.1f;
                    }
                }
            }
            Close(); 
            Global.SliceVM.flushDgv();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void ComboBox_DropDownOpened(object sender, EventArgs e)
        {
            Global.printParaVM.LayersList.Clear();
            for (int i = 0; i < Global.printProject.printLayers.Count(); i++)
            {
                Global.printParaVM.LayersList.Add(i.ToString());
            }
        }
    }
}
